//废弃的页面

import { toast, promptBox } from 'nc-lightapp-front';

export default class RowHandle {
	constructor(comp) {
		this.comp = comp;
	}

	// 点击保存入职信息
	saveOnes = async (selectedRows) => {
		const { props } = this.comp;
		const { emp, editTable, dispatch, form, button } = props;
		const ctrtDate = form.getAllFormValue('hi_psndoc_ctrt');
		const emailDate = form.getFormItemsValue('card', 'email').value;
		const materialDate = editTable.getAllData('material');
		const psncode = form.getFormItemsValue('card', 'psncode').value;
		// console.log('???', selectedRows);
		let postData = {
			ctrt: ctrtDate,
			email: emailDate,
			isCommit: false,
			material: materialDate,
			psncode: psncode,
			pk_org: emp.orgValue.refpk,
			billid: selectedRows[0].values['pk_entryapply'].value
		};
		// console.log('???', form.getFormItemsValue('hi_psndoc_ctrt', 'pk_org'));
		//设置表单必输性？？？
		// form.setFormItemsRequired('hi_psndoc_ctrt',{'contractnum':true,'signdate':true,'pk_majorcorp':true,'pk_org':true})
		// if(form.getFormItemsValue('hi_psndoc_ctrt','signdate').value===null||
		// form.getFormItemsValue('hi_psndoc_ctrt','pk_majorcorp').value===''||
		// form.getFormItemsValue('hi_psndoc_ctrt','pk_org').value===''||
		// form.getFormItemsValue('hi_psndoc_ctrt','contractnum').value===''||
		// form.getFormItemsValue('hi_psndoc_ctrt','termtype').value===null)
		// {
		//     toast({
		//         color: 'danger',
		//         content: emp.language['gx6008-000211'] // 劳动合同信息表单必输项为空
		//     });
		//     return false
		// }
		form.isCheckNow([ 'card', 'hi_psndoc_ctrt' ]);
		try {
			dispatch(
				{
					type: 'emp/handEntry',
					payload: {
						postData: postData
					}
				},
				(res) => {
					if (res.success) {
						dispatch({
							type: 'emp/update',
							payload: {
								addPageStatus: 'browse',
								ctrtBtnDisp: 'none'
							}
						});
						form.setFormStatus('card', 'browse');
						editTable.setStatus('material', 'browse');
						form.setFormStatus('hi_psndoc_ctrt', 'browse');
						button.setButtonVisible({
							save: false
						});
						toast({
							color: 'success',
							content: emp.language['gx6008-000030'] // "保存成功"
						});
					}
				}
			);
		} catch (e) {}
	};

	//编辑按钮
	editOnes = (selectedRows) => {
		const { props, action } = this.comp;
		const { dispatch } = props;
		dispatch({
			type: 'emp/update',
			payload: {
				ctrtBtnDisp: 'inline'
			}
		});
		action.formAct.toEditPage(selectedRows);
	};

	// 点击确认入职
	submitOnes = async (selectedRows) => {
		const { props, action } = this.comp;
		const { emp, editTable, dispatch, form, button } = props;
		action.entryAct.openEntryModal(selectedRows);
	};
}
